#!/bin/bash

. common.sh 

echo MPLAYER

COMPILATEUR="--cc=/usr/bin/gcc-4.2"


cd ${SRC}
curl -O -C - http://kakola.googlecode.com/files/mplayer-rev-32882.tar.gz
tar xvzf mplayer-rev-32882.tar.gz

if [ ! -d "mplayer" ]
then
    REV=`svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer | grep "Checked out revision " | sed -e "s/Checked out revision //g" | sed -e "s/\.//g"`
    if [ "$REV" = "" ]
    then
        echo "Error will getting the revision version of mplayer"
        exit 1
    fi

    cd mplayer || exit 2
    git clone git://git.ffmpeg.org/ffmpeg.git
    if [ -f "mplayer-HEAD-mencoder_VP8_fourcc__2pass_fix.diff" ]
    then
        echo "Apply patch mplayer-HEAD-mencoder_VP8_fourcc__2pass_fix.diff"
        curl -O -C - http://kakola.googlecode.com/files/mplayer-HEAD-mencoder_VP8_fourcc__2pass_fix.diff
        patch -p1 < mplayer-HEAD-mencoder_VP8_fourcc__2pass_fix.diff || echo "ERROR patch -p1 < mplayer-HEAD-mencoder_VP8_fourcc__2pass_fix.diff"
    fi
else
    cd mplayer || exit 2
fi

./configure --prefix=${PREFIX} $COMPILATEUR --extra-cflags="-I${PREFIX}/include/ -I${PREFIX}/include/ -I${PREFIX}/include/a52dec/ -I${PREFIX}/include/lame/ -I$PREFIX/include/ -I${PREFIX}/include/ao -I${PREFIX}/include/ogg  -I${PREFIX}/include/vorbis -I${PREFIX}/include/theora " --extra-ldflags="-L${PREFIX}/lib -L${PREFIX}/lib" --yasm='' || exit 2
make -j 4  || exit 2
make install || exit 2